<?php $this->_extends('../_layouts/default_layout');?>
<?php $this->_block('contents');?>
<script type="text/javascript">
$(function(){
	var old_info;
	$(".edit").click(function(){
		var container = $(this).parent().parent();
		old_info = container.find("input.blur").val();
		container.find("input.blur").focus().blur(function(){
			var id = $(this).next().val();
			var new_info = $(this).val();
			if (new_info != old_info)
			{
				if ($(this).attr("name") == 'gift_card')
				{
					var url = "<?=url('Storage::Product/ShopGiftCardSave')?>&gift_card=" + new_info;
				}
				$.ajax({
					url: url + "&id=" + id,
					type: "GET",
					dataType: "json",
					success:
						function(data)
						{
							if (data != 0)
							{
								$("#gift_card" + data).val(old_info);
							}
						}
				});
			}
		});
	});
});
</script>
<style>
.blur
{
	cursor: pointer;
	border: none;
	width: 50px;
}
</style>
<fieldset><legend>查询条件</legend>
<form method="get">
<?include (Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>平台名称</th>
	<td>
		<select name="platform">
			<option value="">请选择</option>
			<option value="zencart" <?if (isset($_GET['platform']) && $_GET['platform'] == 'zencart'):?>selected="selected"<?endif?> >zencart</option>
			<option value="magento" <?if (isset($_GET['platform']) && $_GET['platform'] == 'magento'):?>selected="selected"<?endif?> >magento</option>
			<option value="ebay" <?if (isset($_GET['platform']) && $_GET['platform'] == 'ebay'):?>selected="selected"<?endif?> >ebay</option>
			<option value="amazon" <?if (isset($_GET['platform']) && $_GET['platform'] == 'amazon'):?>selected="selected"<?endif?> >amazon</option>
			<option value="aliexpress" <?if (isset($_GET['platform']) && $_GET['platform'] == 'aliexpress'):?>selected="selected"<?endif?> >aliexpress</option>
		</select>
	</td>
</tr>
<tr>
	<th>&nbsp;</th>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<table width="50%" class="list_table" id="list">
<tr>
	<td>店铺ID</td>
	<td>店铺名称</td>
	<td>平台名称</td>
	<td>感谢卡代码</td>
	<td>操作</td>
</tr>
<?foreach ($shop as $s):?>
<tr>
	<td><?=$s['id']?></td>
	<td><?=$s['name']?></td>
	<td><?=$s['platform']?></td>
	<td>
		<input type="text" name="gift_card" value="<?=$s['gift_card']?>" class="blur edit" id="gift_card<?=$s['id']?>"/>
		<input type="hidden" value="<?=$s['id']?>" />
	</td>
	<td><a class="edit">编辑</a></td>
</tr>
<?endforeach;?>
</table>
<?php $this->_endblock();?>